package org.spp.voronoi;

import org.spp.utilities.SetUtils;
        
import java.util.ArrayList;
import java.util.List;

/**
 * Vertex3D.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Vertex
 * 
 * Description: class that implements a vertex of the voronoi diagram in case of 
 *              tridimensional vector spaces.
 * 
 * Date: Jul 10, 2011
 */
public class Vertex3D extends Vertex{
            
    /**
     * Constructor for the class Vertex3D
     * @param coordinates 
     */
    public Vertex3D(double[] coordinates) {        
        super(coordinates);        
    }
    
    /**
     * Constructor for the class Vertex3D
     * @param coordinates 
     */
    public Vertex3D (double[][] coordinates) {
        super(coordinates);
    }
      
    /**
     * Compute the outgoing edges from the vertex and store them in the related class attribute
     */
    @Override
    public void computeEdges(){
          
        if (edges.isEmpty()){

            for (int j = 0; j < cells.size(); j++) {

                List<Facet> vertexFacets = cells.get(j).findVertexFacets(this);

                // Each couple of facets generates an edge
                for (int k = 0; k < (vertexFacets.size()-1); k++)
                    for (int h = k+1; h < vertexFacets.size(); h++){
                        
                        List<Facet> edgeFacets = new ArrayList<Facet>();
                        edgeFacets.add(vertexFacets.get(k));
                        edgeFacets.add(vertexFacets.get(h));
                        edges.add(new Edge3D(this, null, cells.get(j).getCentroid(), edgeFacets));
                    }       
            }
            this.edges = SetUtils.findDistincts(this.edges);
        }
    }

} 
     
